import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

void showCustomDialog(BuildContext context, String url, GestureTapCallback onTapAction) {
  showDialog(
    context: context,
    barrierDismissible: false, // Prevent dismiss on tap outside
    builder: (BuildContext context) {
      return Stack(
        alignment: Alignment.bottomCenter,
        children: [
          Dialog(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(12.0),
            ),
            child: Column(
              mainAxisSize: MainAxisSize.min,
              children: [
                InkWell(
                  onTap: onTapAction,
                  child: ClipRRect(
                    borderRadius: const BorderRadius.all(Radius.circular(8)),
                    child: Image.network(
                      url,
                      height: ScreenUtil().screenHeight * 0.6,
                      // width: ScreenUtil().screenWidth * 0.7,
                      fit: BoxFit.cover,
                    ),
                  ),
                ),
              ],
            ),
          ),
          Positioned(
            bottom: 50.0,
            child: ElevatedButton(
              onPressed: () {
                Navigator.of(context).pop(); // Close the dialog
              },
              style: ElevatedButton.styleFrom(
                shape: const CircleBorder(), // 圆形按钮
                padding: const EdgeInsets.all(12), // 内边距让按钮显得更大
                backgroundColor: Colors.transparent, // 按钮背景透明
                foregroundColor: Colors.black, // 图标颜色
                side: const BorderSide(
                  // 边框样式
                  color: Colors.white, // 边框颜色
                  width: 2.0, // 边框宽度
                ),
                elevation: 0, // 去掉阴影
              ),
              child: const Icon(
                Icons.close_outlined,
                size: 24,
                color: Colors.white,
              ),
            ),
          ),
        ],
      );
    },
  );
}
